package com.andy.buyu.server.entity;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

public class ConfAttackType extends BaseEntity{

	private static final long serialVersionUID = 1L;

	public ConfAttackType() {
	}
	
	public ConfAttackType(Long id) {
		super(id);
	}
	
	private Integer attType;
	
	private String fishType;
	
	public static String table() {
		return "conf_attack_type";
	}

	public String getFishType() {
		return fishType;
	}

	public void setFishType(String fishType) {
		this.fishType = fishType;
		if(StringUtils.isNotBlank(fishType)) {
			String[] att = StringUtils.split(fishType, ",");
			fishTypes = new int[att.length];
			for(int i=0;i<att.length;i++) {
				fishTypes[i] = Integer.parseInt(att[i]);
			}
		}
	}

	public Integer getAttType() {
		return attType;
	}

	public void setAttType(Integer attType) {
		this.attType = attType;
	}
	
	private transient int[] fishTypes;
	public boolean canAttack(int fishType) {
		if(fishTypes != null){
			return ArrayUtils.contains(fishTypes, fishType);
		}
		return true;
	}

	
}
